package com.wyp168.renrenfilm.core.controller;

import java.util.Arrays;
import java.util.Map;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wyp168.renrenfilm.core.entity.WatchEntity;
import com.wyp168.renrenfilm.core.service.WatchService;
import com.wyp168.common.utils.PageUtils;
import com.wyp168.common.utils.R;



/**
 * 
 *
 * @author wyp168
 * @email 2721255249@qq.com
 * @date 2022-11-16 18:36:43
 */
@RestController
@RequestMapping("film/watch")
public class WatchController {
    @Autowired
    private WatchService watchService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, String> params){
        PageInfo page = watchService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		WatchEntity watch = watchService.getById(id);

        return R.ok().put("watch", watch);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody WatchEntity watch){
		watchService.saveWatcher(watch);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody WatchEntity watch){
		watchService.updateById(watch);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		watchService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
